$ () ->
	$("#update_btn").click (e) ->
		param =
			id: $(e.target).parent().parent().children().eq(0).html()
			type_name: $(e.target).parent().parent().children().eq(1).children("#type_name").val()

		$.post "/api/admin/manager/update-case-type", param, (res) ->
			if res.status.errCode is 0
				alert "修改成功"
			else
				alert res.status.message

	$(".delete_btn").click (e) ->
		param = 
			id: $(e.target).parent().parent().children().eq(0).html()

		$.post "/api/admin/manager/delete-case-type", param, (res) ->
			if res.status.errCode is 0
				alert "删除成功"
				window.location.reload()
			else
				alert res.status.message

	$("#create_btn").click (e) ->
		param =
			type_name: $("#create_type_name").val()

		$.post "/api/admin/manager/create-case-type", param, (res) ->
			if res.status.errCode is 0
				alert "添加成功"
				window.location.reload()
			else
				alert res.stauts.message
